package com.mmp.common.servlet;

import java.io.File;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mmp.common.util.Common;
import com.mmp.main.util.Default;
import com.mmp.main.util.WebUtil;

public class FileDeleteServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
			IOException {
		
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		
		String fileName = WebUtil.decodeQueryStringParameter(request,"file_name");
		
		try {
			new File(Default.FILES_UPLOAD_DIR + fileName).delete();
		} catch (Exception e) {
			// File permission problems are caught here.
			Common.log(e);
		}
	}

}
